import { onMounted, ref } from 'vue'
import { useRoute } from 'vue-router'
import { getCategory } from '@/api/category.js'

export function useCategory() {
  const route = useRoute()
  const categoryData = ref({})

  async function getCategoryData() {
    const res = await getCategory(route.params.id)
    categoryData.value = res.result

    console.log('打印category', res)
  }

  onMounted(() => {
    getCategoryData()
  })
  return {
    categoryData,
  }
}
